package redis

func (k *key) HSet(field string, value any) BoolResult {
	return k.cmd("HSET", k.key, field, value)
}

func (k *key) HSetNX(field string, value any) BoolResult {
	return k.cmd("HSETNX", k.key, field, value)
}

func (k *key) HGet(field string) ValueResult {
	return k.cmd("HGET", k.key, field)
}

func (k *key) HExists(field string) BoolResult {
	return k.cmd("HEXISTS", k.key, field)
}

func (k *key) HDel(field ...string) IntResult {
	args := []any{k.key}
	for _, f := range field {
		args = append(args, f)
	}
	return k.cmd("HDEL", args...)
}

func (k *key) HLen() IntResult {
	return k.cmd("HLEN", k.key)
}

func (k *key) HStrLen(field string) IntResult {
	return k.cmd("HSTRLEN", k.key, field)
}

func (k *key) HIncrBy(field string, increment int) IntResult {
	return k.cmd("HINCRBY", k.key, field, increment)
}

func (k *key) HIncrByFloat(field string, increment float64) FloatResult {
	return k.cmd("HINCRBYFLOAT", k.key, field, increment)
}

func (k *key) HMSet(fieldValues map[string]any) BoolResult {
	args := []any{k.key}
	for k, v := range fieldValues {
		args = append(args, k, v)
	}
	return k.cmd("HMSET", args...)
}

func (k *key) HMGet(field ...string) ListResult {
	args := []any{k.key}
	for _, f := range field {
		args = append(args, f)
	}
	return k.cmd("HMGET", args...)
}

func (k *key) HKeys() StringListResult {
	return k.cmd("HKEYS", k.key)
}

func (k *key) HVals() ListResult {
	return k.cmd("HVALS", k.key)
}

func (k *key) HGetAll() MapResult {
	return k.cmd("HGETALL", k.key)
}

func (k *key) HScan(args *ScanArgs) error {
	return k.scan("HSCAN", args)
}
